<%@page import="com.sjyy.areadict.model.*" %>

<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib tagdir="/WEB-INF/tags/simpletable" prefix="simpletable"%>
<%@ include file="/commons/taglibs.jsp" %>

<rapid:override name="head">
	<title>Areadict维护</title>
	
	<script src="${ctx}/scripts/rest.js" ></script>
	<link href="<c:url value="/widgets/simpletable/simpletable.css"/>" type="text/css" rel="stylesheet">
	<script type="text/javascript" src="<c:url value="/widgets/simpletable/simpletable.js"/>"></script>
	<script src="<c:url value="/scripts/jquery.js"/>" type="text/javascript"></script>
	<script src="<c:url value="/scripts/application.js"/>" type="text/javascript"></script>
	<script type="text/javascript" >
		$(document).ready(function() {
			window.simpleTable = new SimpleTable('queryForm',${page.thisPageNumber},${page.pageSize},'${pageRequest.sortColumns}');
		});
	</script>
</rapid:override>

<rapid:override name="content">
	<form id="queryForm" name="queryForm" method="get" style="display: inline;">
	<div class="queryPanel">
		<fieldset>
			<table>
				<div class="form-group inline icon">
				<i class="icon-align-justify"></i>	
					<input placeholder="名称" value="${query.areaName}" id="areaName" name="areaName" maxlength="32"  class="form-field"/>
					<br/>
				</div>
				
				<div class="form-group inline icon">
				<!--  	<input placeholder="父区域ID" value="${query.parentAreaId}" id="parentAreaId" name="parentAreaId" maxlength="10"  class="form-field col-1-5"/>-->
					
					<select class="form-field col-2" value="${query.parentAreaId}" name="parentAreaId" id="parentAreaId">
					<option value="">全部</option>
					<c:forEach items="${areaIdList}" var="item">								
						<option value="${item.key }" 
						<c:if test="${item.key eq query.parentAreaId}">
							selected="selected"
						</c:if>
						>${item.value }</option>
					</c:forEach>						
				</select>
					<br/>
				</div>
			<button type="submit" class="btn btn-default" onclick="getReferenceForm(this).action='${ctx}/areadict'">查询</button>
			<label>		</label><label>		</label><label>		</label>
			
			</table>
		<div class="handleControl">
			<button type="button" class="btn btn-default" onclick="window.location = '${ctx}/areadict/new'">新增</button>
			<button type="button" class="btn btn-default" onclick="doRestBatchDelete('${ctx}/areadict','items',document.forms.queryForm)">删除</button>
		<div>
		</fieldset>
		
	
	</div>
	
	<div class="gridTable">	
		<table width="100%"  border="0" cellspacing="0" class="table text-center">
		  <thead>			  
			  <tr>
				<th style="width:1px;"><input type="checkbox" onclick="setAllCheckboxState('items',this.checked)"></th>
				<th sortColumn="area_name" width="20%">名称</th>
				<th sortColumn="parent_area_id" width="20%">父区域</th>
				<th sortColumn="area_index" width="20%">排序</th>
				<th sortColumn="municipality" width="20%">直辖市</th>
				<th style="white-space:nowrap;"width="20%">操作</th>
			  </tr>			  
		  </thead>
		  <tbody>
		  	  <c:forEach items="${page.result}" var="item" varStatus="status">
			  <tr class="${status.count % 2 == 0 ? 'odd' : 'even'}">
				<td><input type="checkbox" name="items" value="${item.areadictId}"></td>
				<td><c:out value='${item.areaName}'/>&nbsp;
				
				</td>
				<td>
				<c:forEach items="${areaIdList}" var="areaIdListItem">								
						<c:if test="${areaIdListItem.key eq item.parentAreaId}">
						<c:out value='${areaIdListItem.value }'/>&nbsp;
						</c:if>
					</c:forEach>
				</td>
				<td><c:out value='${item.areaIndex}'/>&nbsp;</td>
				<td>
				<c:if test="${item.municipality == 1}"> 省份 </c:if>
				<c:if test="${item.municipality == 2}"> 城市 </c:if>
				<c:if test="${item.municipality == 3}"> 区域 </c:if>&nbsp;
				</td>
				<td>
					<a href="${ctx}/areadict/${item.areadictId}">查看</a>&nbsp;&nbsp;
					<a href="${ctx}/areadict/${item.areadictId}/edit">修改</a>&nbsp;&nbsp;
					<a href="${ctx}/areadict/${item.areadictId}" onclick="doRestDelete(this,'你确认删除?');return false;">删除</a>
				</td>
			  </tr>
			  
		  	  </c:forEach>
		  </tbody>
		</table>
	
		<simpletable:pageToolbar page="${page}">
		</simpletable:pageToolbar>
		
	</div>
	</form>
</rapid:override>
<rapid:override name="script"><script></script></rapid:override>
<%@ include file="base.jsp" %>
